home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / comm / thor / DLManager.lha / DLManager.thor < prev   
Text File  |  1998-01-03  |  14KB  |  627 lines

  1. /*
  2. **   $Filename: DLManager.thor
  3. **
  4. **   $VER: DLManager v1.5 ©1996-1998
  5. **
  6. **   Copyright 1996-1998, Troy E. Bouchard.
  7. **
  8. **   Author: Troy E. Bouchard
  9. **   E-Mail: tbouchar@ptialaska.net
  10. **
  11. **   Library Files needed:
  12. **         bbsread.library (of course)
  13. **         rexxarplib.library (get it from Aminet!)
  14. **         rexxsupport.library (get it from Aminet!)
  15. **
  16. */
  17.  
  18. SIGNAL ON SYNTAX
  19. SIGNAL ON HALT
  20.  
  21. EVE_ENTERMSG = 0
  22.  
  23. /* Find our Thor Port and number! */
  24. p = Address() || ' ' || show('P',,)
  25.     ThorPort = pos('THOR.',p)
  26.  
  27.     if ThorPort > 0 then ThorPort = word(substr(p,ThorPort),1)
  28. else
  29.     do
  30.     say "Can't seem to find the Thor port!"
  31.     exit 10
  32.     End
  33.  
  34. /* Load the BBSRead library up! */
  35. if ~show('p', 'BBSREAD') then
  36. do
  37.    address command
  38.       "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  39.      "WaitForPort BBSREAD"
  40. End
  41.  
  42. if ~Show('L','rexxarplib.library') then
  43. do
  44.    if ~AddLib('rexxarplib.library',0,-30,0) then
  45.    do
  46.       Address(ThorPort)
  47.       'REQUESTNOTIFY TEXT '"Couldn't open rexxarplib.library"' BT "_Exiting!"'
  48.       exit 5
  49.    end
  50. end
  51.  
  52. if ~Show('L','rexxsupport.library') then
  53. do
  54.    if ~AddLib('rexxsupport.library',0,-30,0) then
  55.    do
  56.       Address(ThorPort)
  57.       'REQUESTNOTIFY TEXT '"Couldn't open rexxsupport.library"' BT "_Exiting!"'
  58.       exit 5
  59.    end
  60. end
  61.  
  62. options results
  63.  
  64.    MyPort = OpenPort(DLPORT)
  65.    if MyPort = 0 then
  66.    do
  67.       Address(ThorPort)
  68.       'REQUESTNOTIFY TEXT '"Couldn't open the port"' BT "_Exiting!"'
  69.       exit 5
  70.    end
  71.  
  72.    address AREXX ,
  73.      "'Call CreateHost(DLHOST,DLPORT)'"
  74.  
  75.    do i = 1 to 10
  76.       if ~Showlist('P',DLHOST) then call delay 50
  77.       else leave i
  78.    end
  79.  
  80.    if i = 10 & ~Showlist('P',DLHOST) then
  81.    do
  82.       Address(ThorPort)
  83.       'REQUESTNOTIFY TEXT '"Couldn't open the Host"' BT "_Exiting!"'
  84.       exit 5
  85.    end
  86.  
  87.    Call CreateWIN()
  88.  
  89. WaitStuff:
  90.    fini = 0
  91.  
  92.    do forever
  93.       if fini = 1 then leave
  94.       t = waitpkt(DLPORT)
  95.       do i = 1
  96.      p = getpkt(DLPORT)
  97.      if c2d(p) = 0 then leave i
  98.      cmd = getarg(p)
  99.      j = reply(p,0)
  100.      Select
  101.         When cmd = CLOSEWINDOW then do
  102.            Call Quit()
  103.         end
  104.         When cmd = GETSYSTEM then do
  105.            Call GetSystem()
  106.            win.txt = 'Current System: 'TB_SYSTEM
  107.            Call WindowText(DLHOST, win.txt)
  108.         end
  109.         When cmd = NEWLIST then do
  110.            Call NewList()
  111.         end
  112.         When cmd = WRITEMSG then do
  113.            Call WriteMSG()
  114.         end
  115.         When cmd = DELLIST then do
  116.            Call DeleteList
  117.         end
  118.         When cmd = QUIT then do
  119.            Call Quit()
  120.         end
  121.         When cmd = ABOUT then do
  122.            Call About
  123.         end
  124.         When cmd = EDIT then do
  125.            Call Edit
  126.         end
  127.         When cmd = DELETEU then do
  128.            Call LeaveAlone()
  129.         end
  130.         otherwise nop
  131.      end
  132.       end
  133.    end
  134. Return
  135.  
  136. CreateWIN:
  137.    voffseta=0
  138.    voffsetb=0
  139.    gad. = ""
  140.    gad.0 = 28
  141.  
  142.    win.idcmp = "+CLOSEWINDOW+GADGETUP"
  143.    win.flags = "+WINDOWCLOSE+WINDOWDEPTH+BACKFILL+ACTIVATE"
  144.    win.title = "DLManager v1.5"
  145.  
  146.    gad.1.x = 30
  147.    gad.1.y = 38+voffseta
  148.    gad.1.name = "GETSYSTEM"
  149.    gad.1.text = " Get System "
  150.    gad.1.reportstring = "%d"
  151.  
  152.    gad.2.x = 30
  153.    gad.2.y = 56+voffseta
  154.    gad.2.name = "NEWLIST"
  155.    gad.2.text = "New/Add List"
  156.    gad.2.reportstring = "%d"
  157.  
  158.    gad.3.x = 156
  159.    gad.3.y = 38+voffseta
  160.    gad.3.name = "WRITEMSG"
  161.    gad.3.text = " Write Mesg "
  162.    gad.3.reportstring = "%d"
  163.  
  164.    gad.4.x = 156
  165.    gad.4.y = 56+voffseta
  166.    gad.4.name = "DELLIST"
  167.    gad.4.text = " Delete List"
  168.    gad.4.reportstring = "%d"
  169.  
  170.    gad.5.x = 30
  171.    gad.5.y = 74+voffseta
  172.    gad.5.name = "QUIT"
  173.    gad.5.text = "    Quit    "
  174.    gad.5.reportstring = "%d"
  175.  
  176.    gad.6.x = 156
  177.    gad.6.y = 74+voffseta
  178.    gad.6.name = "ABOUT"
  179.    gad.6.text = "    About   "
  180.    gad.6.reportstring = "%d"
  181.  
  182.    gad.7.x = 30
  183.    gad.7.y = 92+voffseta
  184.    gad.7.name = "EDIT"
  185.    gad.7.text = "    Edit    "
  186.    gad.7.reportstring = "%d"
  187.  
  188.    gad.8.x = 156
  189.    gad.8.y = 92+voffseta
  190.    gad.8.name = "DELETEU"
  191.    gad.8.text = " Delete User"
  192.    gad.8.reportstring = "%d"
  193.  
  194.    call SetReqColor(DLHOST,BACKGROUND,4) /* Color the Background */
  195.  
  196. /* Open the window and set the gadgets! */
  197.    call OpenWindow(DLHOST, 0, 0, 285, 112, win.idcmp, win.flags, win.title)
  198.  
  199.    window.text = '   Current System: ~None~'
  200.    Call WindowText(DLHOST, window.text)
  201.  
  202.    CNT = 0
  203.  
  204.    do n = 1 to gad.CNT
  205.       if gad.n.length = "" then
  206.      call Addgadget(DLHOST, gad.n.x, gad.n.y, ,
  207.         gad.n.name, gad.n.text, gad.n.reportstring)
  208.       else
  209.      call Addgadget(DLHOST, gad.n.x, gad.n.y, ,
  210.         gad.n.name, gad.n.text, gad.n.reportstring, ,
  211.            gad.n.length)
  212.    end
  213.  
  214. /* Color the Gadgets and activate em! (set activate -> ON
  215.    Call SetGadget(DLHOST, GETSYSTEM, ON)
  216.    Call SetGadget(DLHOST, NEWLIST,   ON)
  217.    Call SetGadget(DLHOST, WRITEMSG,  ON)
  218.    Call SetGadget(DLHOST, DELLIST,   ON)
  219.    Call SetGadget(DLHOST, QUIT,      ON)
  220.    Call SetGadget(DLHOST, ABOUT,     ON)
  221.    Call SetGadget(DLHOST, EDIT,      ON) */
  222. Return
  223.  
  224.  
  225. AddTDL:
  226.    Call GetSystemPath()
  227.  
  228.    Address(ThorPort)
  229.    'RequestFile Title "Select the .tdl file" ID "'DataPath'".tdl FP PAT "#?.tdl"'
  230.    if(rc = 5) then
  231.    do
  232.       'RequestNotify Text "Request Aborted!" BT "_Wow!"'
  233.       Call WaitStuff
  234.    end
  235.  
  236.    choice = result
  237.  
  238.    if ~Exists(choice) then
  239.    do
  240.       Call Open out, choice, 'w'
  241.       Call Close out
  242.    end
  243. Return(Choice)
  244.  
  245. NewList:
  246.    Call AddTDL
  247.    Call AutoManAdd
  248. Return
  249.  
  250. WriteCC:
  251.    Address BBSRead
  252.    'BufMode CopyBack'
  253.    CCAddrStr = ''
  254.    hdr = 'Cc: '
  255.    WAddressStr = hdr||ADDR.i
  256.    i=i+1
  257.    Do j = i to ADDR.COUNT
  258.       Interpret 'NextAddress = ADDR.'j
  259.       if Length(WAddressStr','NextAddress) > 246 then
  260.       do
  261.      CCAddrStr = CCAddrStr||WAddressStr||','||'0a'x
  262.      WAddressStr = ''
  263.       End
  264.       else WAddressStr = WAddressStr','
  265.       WAddressStr = WAddressStr||NextAddress
  266.    End
  267.  
  268.    if WAddressStr > '' then CCAddrStr = CCAddrStr||WAddressStr||'0a'x
  269.  
  270.    TmpFile = 'T:TDL.tmp'
  271.    Call Open out, TmpFile, 'W'
  272.    Call WriteLN out, CCAddrStr
  273.    Call Close out
  274.  
  275.    TmpOpen = Open(out, TmpFile, 'R')
  276.    if (TmpOpen) then do
  277.       TmpLen = Seek(out,0,'E')
  278.       Call Seek(out,0,'B')
  279.       nroflines = 0
  280.       do until (Seek(out,0)=TmpLen)
  281.      HdrLine = ReadLN(out)
  282.      Call Open in, DataPath||EVENT.MSGFILE, 'A'
  283.      Call WriteLN in, HdrLine
  284.      Call Close in
  285.      nroflines = nroflines + 1
  286.    end
  287.    Call Close out
  288.  
  289.    Address Command 'Delete >NIL: 'TmpFile
  290.    'BufMode EndCopyBack'
  291. Return
  292.  
  293. WriteMSG:
  294.    Call GetSig()      /* get the pathway to the sig file */
  295.    Call AddTDL()      /* get the distribution list         */
  296.    Call GetSystemPath()   /* get the pathway for the system  */
  297.  
  298.    Drop EVENT. /* make sure you free up the event */
  299.    Drop Addr.  /* make sure you free up the event */
  300.  
  301.    address(BBSREAD)
  302.    'UNIQUEMSGFILE bbsname "'TB_SYSTEM'" stem "'TDLFILE'"'
  303.    if(rc ~= 0) then
  304.    do
  305.       Address(ThorPort)
  306.       'REQUESTNOTIFY TEXT "'BBSREAD.LASTERROR'" BT "_OK"'
  307.       Return
  308.    end
  309.  
  310.    EVENT.CONFERENCE = 'EMail'
  311.    EVENT.MSGFILE    = TDLFILE.FILEPART
  312.  
  313.    Call Open out, Choice, 'R'
  314.  
  315.    n = 0
  316.    do while ~eof(out)
  317.       Address = readln(out)
  318.       if Address = '' then leave
  319.       n = n+1
  320.       Interpret 'ADDR.'n' = Address'
  321.    end
  322.  
  323.    ADDR.COUNT = n
  324.    call Close(out)
  325.  
  326.    do i=1 to ADDR.COUNT
  327.       Interpret 'ADDR.'i'= GetListAddr(ADDR.'i')'
  328.    End
  329.  
  330.    Interpret 'EVENT.TONAME = GetListName(Choice)'
  331.  
  332.    AddressStr = ADDR.1
  333.    Do i = 2 to ADDR.COUNT
  334.       Interpret 'NextAddress = ADDR.'i
  335.       if Length(AddressStr','NextAddress) > 246 then
  336.       do
  337.      EVENT.TOADDR = AddressStr
  338.      Call WriteCC ; leave
  339.       End
  340.       else AddressStr = AddressStr','
  341.       AddressStr = AddressStr||NextAddress
  342.    End
  343.  
  344.    EVENT.TOADDR = AddressStr
  345.  
  346. /* Append the Sig file to the message. */
  347.    SigOpen = Open(out, SigFile, 'R')
  348.    if (SigOpen) then do
  349.       SigLen = Seek(out,0,'E')
  350.       Call Seek(out,0,'B')
  351.       nroflines = 0
  352.       do until (Seek(out,0)=SigLen)
  353.      Sig = ReadLN(out)
  354.      Call Open SigOut, TDLFILE.NAME, 'A'
  355.      Call WriteLN SigOut, Sig
  356.      Call Close SigOut
  357.      nroflines = nroflines + 1
  358.    end
  359.    Call Close out
  360.  
  361.    Address(ThorPort)
  362.    'REQUESTSTRING TITLE "Please enter your subject:" BT "_Ok|_Cancel" ID "DLManager v1.5" MAXCHARS 100'
  363.    EVENT.SUBJECT = result
  364.    if( rc ~= 0 | EVENT.SUBJECT = '') then
  365.       EVENT.SUBJECT = '(No Subject)' /* You always have to have a s